#ifndef _ML_TRAJECTORY_H_
#define _ML_TRAJECTORY_H_
#include "MLDataPoint.h"

class CMLTrajectory
{
public:
	// Constructor and Destructor
	CMLTrajectory(void);
	CMLTrajectory(const CMLTrajectory& src);
	~CMLTrajectory(void);

public:
	// Properties
	inline std::wstring GetName() const { return m_wstrName; };
	inline void SetName(const std::wstring& wstrName) { m_wstrName = wstrName; };
	inline int GetPointCount() const { return (int)m_vPoints.size(); };
	inline const mylablib::CMLDataPoint& GetPoint(int nIndex) const { return m_vPoints[nIndex]; };
	inline void SetPoint(int nIndex, const mylablib::CMLDataPoint& dataPoint) { m_vPoints[nIndex] = dataPoint; };

public:
	// Methods
	inline CMLTrajectory& operator =(const CMLTrajectory& src)
	{
		m_vPoints = src.m_vPoints;
		m_wstrName = src.m_wstrName;
		return *this;
	}

	inline bool Equal(const CMLTrajectory& dest)
	{
		if (m_vPoints.size() != dest.m_vPoints.size())
			return false;
		else
		{
			for (int i=0; i<(int)m_vPoints.size(); i++)
			{
				if (m_vPoints[i] != dest.m_vPoints[i])
					return false;
			}
			return true;
		}
	}

	inline void AddPoint(const mylablib::CMLDataPoint& dataPoint) { m_vPoints.push_back(dataPoint); };
	inline void InsertPoint(int nIndex, const mylablib::CMLDataPoint& dataPoint) { m_vPoints.insert(m_vPoints.begin()+nIndex, dataPoint); };
	inline void RemovePoint(int nIndex) { m_vPoints.erase(m_vPoints.begin() + nIndex); };
	inline void Resize(int nPointCount) { m_vPoints.resize((size_t)nPointCount); };

private:
	// Fields
	std::vector<mylablib::CMLDataPoint> m_vPoints;
	std::wstring m_wstrName;
};

class CMLTrajectoryCollection
{
public:
	// Constructor and Destructor
	CMLTrajectoryCollection(void);
	CMLTrajectoryCollection(const CMLTrajectoryCollection& src);
	~CMLTrajectoryCollection(void);

public:
	// Properties
	inline int Count(void) const { return (int)m_vTrajs.size(); };
	inline const CMLTrajectory& Get(int nIndex) const { return m_vTrajs[nIndex]; };
	inline CMLTrajectory& Get(int nIndex) { return m_vTrajs[nIndex]; };
	inline void Set(int nIndex, const CMLTrajectory& traj) { m_vTrajs[nIndex ] =traj; };

	inline const CMLTrajectory& Back(void) const { return m_vTrajs.back(); };
	inline CMLTrajectory& Back(void) { return m_vTrajs.back(); };

public:
	// Methods
	inline CMLTrajectoryCollection& operator=(const CMLTrajectoryCollection& src)
	{
		m_vTrajs = src.m_vTrajs;
		return *this;
	}

	inline void Clear(void) { m_vTrajs.clear(); };

	inline void Resize(int nSize) { m_vTrajs.resize((size_t)nSize); };

	inline void Add(const CMLTrajectory& traj) { m_vTrajs.push_back(traj); };

	inline void Remove(int nIndex) { m_vTrajs.erase(m_vTrajs.begin() + nIndex); };

	inline void Delete(int nIndex, int nCount) { m_vTrajs.erase(m_vTrajs.begin()+nIndex, m_vTrajs.begin()+(nIndex+nCount)); };

	inline int GetTotalPointCount(void)
	{
		int sum = 0;
		for (int i=0; i<(int)m_vTrajs.size(); i++)
		{
			sum += m_vTrajs[i].GetPointCount();
		}
		return sum; 
	}


private:
	// Fields
	std::vector<CMLTrajectory> m_vTrajs;
};

#endif
